package com.zombie.effect;


import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.zombie.Constants;
import com.zombie.ResourceManager;

public class FogEffect extends AbstractEffect {

	boolean moveLeft = false;
	TextureRegion fog;
	float scale = 1;
	
	public FogEffect(float scale){
		this.scale = scale;
		renderGroup = Constants.GROUP_LAST;
		fog = ResourceManager.getImage("clouds");
	}
	
	@Override
	public void update(int delta) {
		if (moveLeft)
			position.x-=delta*0.01f;
		else
			position.x+=delta*0.01f;
		
		if (position.x < -fog.getRegionWidth()*scale)
			moveLeft = false;
		if (position.x > Constants.MAP_WIDTH+fog.getRegionWidth())
			moveLeft = true;
	}

	@Override
	public void draw(SpriteBatch batch, ShapeRenderer shapeBatch) {
		batch.draw(fog, position.x, position.y,
				fog.getRegionWidth()/2, fog.getRegionHeight()/2,
				fog.getRegionWidth(), fog.getRegionHeight(), scale, scale, 0);
	}
	
	@Override
	public void remove() {
	
	}
}
